package com.logic.modular.game.player.bag.service.handler;

import com.comment.pojo.domain.logic.core.CoreProp;
import com.logic.modular.game.player.bag.service.BagItemServiceImpl;
import com.logic.modular.gameCore.cultivate.prop.CorePropServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Map;
@Service

public  class BaseHandler {
    @Resource
    public BagItemServiceImpl bagItemService;

    public void tryObtainPropByProp(Long playerId, Long propId, BigDecimal num) {
        CoreProp coreProp = CorePropServiceImpl.getCache(propId);
        Map<Long, Integer> userValue = coreProp.getUseValue();
        if (!userValue.isEmpty()) {
            // 把获取的数量加入到背包
            userValue.forEach((k, v) -> bagItemService.obtainBagItem(playerId, k, new BigDecimal(v).multiply(num)));
        }
    }
}
